struct Solution {}
impl Solution {
  pub fn simplify_path(path: String) -> String {
  let mut stack = vec![""];
  path.split('/').for_each(|d| {
    match d {
      "." | "" => {}
      ".." => {
        if stack.len() > 1 {
          stack.pop();
        }
      }
      d => {
        stack.push(d);
      }
    }
  });
  if stack.len() == 1 { "/".to_string() } else { stack.join("/") }
  }
}